const mysql = require('mysql2');

const query = function (sql, callback) {
    const connection = mysql.createConnection({
        host: '127.0.0.1',
        user: 'rootserver',
        password: '123456',
        database: 'homedb',
        port: 3306,
    });

    connection.execute(sql, (error, results, fields) => {
        if (error) {
            callback(error);
        } else {
            callback(results);
        }
        connection.end();
    });
}

// 导出模块中的函数
module.exports = {
    query: query
};
